Ubuntu 16.04
Sponsored Link

Nginx : Reverse Proxy Settings#2
2016/07/07
 
Configure Nginx for Reverse Proxy Settings which also forwards WebSocket.
[1] For exmaple, configure Nginx to set proxy on /chat for an application which works on port 1337 of backend server. The sample application is from here (section [3]).
root@www:~#
vi /etc/nginx/sites-available/default
# change like follows in "server" section

    server {
        listen      80 default_server;
        listen      [::]:80 default_server;
        server_name www.srv.world;

        location /socket.io/ {
            proxy_pass http://dlp.srv.world:1337/socket.io/;
            proxy_http_version 1.1;
            proxy_set_header   Upgrade $http_upgrade;
            proxy_set_header   Connection "upgrade";
        }

        location /chat {
            proxy_pass         http://dlp.srv.world:1337/;
            proxy_http_version 1.1;
            proxy_set_header   Upgrade $http_upgrade;
            proxy_set_header   Connection "upgrade";
        }

        location / {
            proxy_pass http://dlp.srv.world/;
        }
    }

root@www:~#
systemctl restart nginx

  Access to the sample App to make sure it works normally on proxy environment.
 
Tweet